<?php


namespace app\admin\controller;


use app\admin\model\HouseErr as HouseErrModel;
use app\common\controller\AdminController;
use think\Exception;

class HouseErr extends AdminController {

    protected $contrAsName = 'house';
    public $levelConfig = [
        1 => ['getlist'],
        2 => ['deal'],
        4 => [],
        8 => []
    ];

    /**
     * 纠错列表
     * @return false|string
     */
    public function getList() {
        try {
            $params = $this->checkParams('id');
            if ($params === false) return $this->resErr();
            list($count, $data) = HouseErrModel::getList($params);
            return $this->resData('success', compact('data', 'count'));
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 处理
     */
    public function deal() {
        try {
            $params = $this->checkParams('id');
            if ($params === false) return $this->resErr();
            HouseErrModel::deal($params);
            return $this->resData('操作成功', []);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

}